package com.esri.core.tasks.ags.geoprocessing;

import com.esri.core.internal.io.handler.h;
import com.esri.core.internal.io.handler.n;
import com.esri.core.internal.util.d;
import com.esri.core.io.EsriServiceException;
import com.esri.core.io.UserCredentials;
import com.esri.core.tasks.ags.geoprocessing.GPTaskInfo;
import java.util.ArrayList;
import java.util.Map;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class GPServiceInfo {
    private String _currentVersion;
    private GPTaskInfo.ExecutionType _executionType;
    private int _maximumRecords;
    private String _resultMapServerName;
    private String _serviceDescription;
    private String[] _tasks;

    public static GPServiceInfo fromUrl(String str) throws Exception {
        return fromJson(h.a(str, (Map<String, String>) null, (n) null));
    }

    public static GPServiceInfo fromUrl(String str, UserCredentials userCredentials) throws Exception {
        return fromJson(h.a(str, (Map<String, String>) null, n.a(str, userCredentials)));
    }

    public static GPServiceInfo fromJson(JsonParser jsonParser) throws Exception {
        GPServiceInfo gPServiceInfo = new GPServiceInfo();
        if (!d.c(jsonParser)) {
            throw new EsriServiceException("Unable to parse the Response for this GPTaskInfo.");
        }
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if ("currentVersion".equals(currentName)) {
                gPServiceInfo.setCurrentVersion(jsonParser.getText());
            } else if ("serviceDescription".equals(currentName)) {
                gPServiceInfo.setServiceDescription(jsonParser.getText());
            } else if ("maximumRecords".equals(currentName)) {
                gPServiceInfo.setMaximumRecords(jsonParser.getIntValue());
            } else if ("resultMapServerName".equals(currentName)) {
                gPServiceInfo.setResultMapServerName(jsonParser.getText());
            } else if ("executionType".equals(currentName)) {
                gPServiceInfo.setExecutionType(GPTaskInfo.ExecutionType.fromString(jsonParser.getText()));
            } else if ("tasks".equals(currentName)) {
                if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY && jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                    ArrayList arrayList = new ArrayList();
                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                        arrayList.add(jsonParser.getText());
                    }
                    gPServiceInfo.setTasks((String[]) arrayList.toArray(new String[0]));
                }
            } else {
                jsonParser.skipChildren();
            }
        }
        return gPServiceInfo;
    }

    public String[] getTasks() {
        return this._tasks;
    }

    private void setTasks(String[] strArr) {
        this._tasks = strArr;
    }

    public GPTaskInfo.ExecutionType getExecutionType() {
        return this._executionType;
    }

    private void setExecutionType(GPTaskInfo.ExecutionType executionType) {
        this._executionType = executionType;
    }

    public String getResultMapServerName() {
        return this._resultMapServerName;
    }

    private void setResultMapServerName(String str) {
        this._resultMapServerName = str;
    }

    public int getMaximumRecords() {
        return this._maximumRecords;
    }

    private void setMaximumRecords(int i) {
        this._maximumRecords = i;
    }

    public String getServiceDescription() {
        return this._serviceDescription;
    }

    private void setServiceDescription(String str) {
        this._serviceDescription = str;
    }

    public String getCurrentVersion() {
        return this._currentVersion;
    }

    private void setCurrentVersion(String str) {
        this._currentVersion = str;
    }
}
